package com.ruoyi.project.datareport.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.datareport.domain.RyDepotItems;
import com.ruoyi.project.datareport.service.IRyDepotItemsService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 单据子（出入库记录）Controller
 * 
 * @author 萧雪
 * @date 2022-11-17
 */
@RestController
@RequestMapping("/datareport/ryDepotItems")
public class RyDepotItemsController extends BaseController
{
    @Autowired
    private IRyDepotItemsService ryDepotItemsService;

    /**
     * 查询单据子（出入库记录）列表
     */
    @PreAuthorize("@ss.hasPermi('datareport:ryDepotItems:list')")
    @GetMapping("/list")
    public TableDataInfo list(RyDepotItems ryDepotItems)
    {
        startPage();
        List<RyDepotItems> list = ryDepotItemsService.selectRyDepotItemsList(ryDepotItems);
        return getDataTable(list);
    }

    /**
     * 导出单据子（出入库记录）列表
     */
    @PreAuthorize("@ss.hasPermi('datareport:ryDepotItems:export')")
    @Log(title = "单据子（出入库记录）", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RyDepotItems ryDepotItems)
    {
        List<RyDepotItems> list = ryDepotItemsService.selectRyDepotItemsList(ryDepotItems);
        ExcelUtil<RyDepotItems> util = new ExcelUtil<RyDepotItems>(RyDepotItems.class);
        util.exportExcel(response, list, "单据子（出入库记录）数据");
    }

    /**
     * 获取单据子（出入库记录）详细信息
     */
    @PreAuthorize("@ss.hasPermi('datareport:ryDepotItems:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(ryDepotItemsService.selectRyDepotItemsById(id));
    }

    /**
     * 新增单据子（出入库记录）
     */
    @PreAuthorize("@ss.hasPermi('datareport:ryDepotItems:add')")
    @Log(title = "单据子（出入库记录）", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RyDepotItems ryDepotItems)
    {
        return toAjax(ryDepotItemsService.insertRyDepotItems(ryDepotItems));
    }

    /**
     * 修改单据子（出入库记录）
     */
    @PreAuthorize("@ss.hasPermi('datareport:ryDepotItems:edit')")
    @Log(title = "单据子（出入库记录）", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RyDepotItems ryDepotItems)
    {
        return toAjax(ryDepotItemsService.updateRyDepotItems(ryDepotItems));
    }

    /**
     * 删除单据子（出入库记录）
     */
    @PreAuthorize("@ss.hasPermi('datareport:ryDepotItems:remove')")
    @Log(title = "单据子（出入库记录）", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ryDepotItemsService.deleteRyDepotItemsByIds(ids));
    }
}
